<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ page import="com.lukebang.util.RSAUtils"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.security.interfaces.*"%>
<c:set var="ctxPath" value="${pageContext.request.contextPath}"
	scope="application" />
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="description" content="">
<meta name="author" content="ThemeBucket">
<link rel="shortcut icon" type="../image/png">
<title>未付款订单</title>
<link rel="stylesheet"
	href="${ctxPath}/static/js/data-tables/DT_bootstrap.css" />
<link rel="stylesheet" type="text/css"
	href="${ctxPath}/static/js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
<link href="${ctxPath}/static/css/style.css" rel="stylesheet">
<link href="${ctxPath}/static/css/style-responsive.css" rel="stylesheet">
<link rel="shortcut icon" type="image/x-icon"
	href="${ctxPath }/static/images/lukebang320.ico" media="screen" />
<link rel="icon" href="${ctxPath }/static/images/lukebang320.ico"
	type="image/x-icon" />
<link rel="bookmark" href="${ctxPath }/static/images/lukebang320.ico"
	type="image/x-icon" />
<!-- <style type="text/css">
td {
	text-align: center;
}

th {
	text-align: center;
}
</style> -->
<%
	HashMap<String, Object> map = RSAUtils.getKeys();
	//生成公钥和私钥    
	RSAPublicKey publicKey = (RSAPublicKey) map.get("public");
	RSAPrivateKey privateKey = (RSAPrivateKey) map.get("private");
	session.setAttribute("privateKey", privateKey);//私钥保存在session中，用于解密  
	//公钥信息保存在页面，用于加密  
	String publicKeyExponent = publicKey.getPublicExponent().toString(16); //公钥指数   
	String publicKeyModulus = publicKey.getModulus().toString(16); //模    
	request.setAttribute("publicKeyExponent", publicKeyExponent);
	request.setAttribute("publicKeyModulus", publicKeyModulus);
%>
</head>
<body class="sticky-header"
	onload="indexmenu('${oneMenu}','${twoMenu}');">
	<%@ include file="../index/index.jsp"%>
	<section>
		<div class="main-content" style="overflow-y: auto">
			<!-- 地址栏-->
			<div class="page-heading">
				<h3>鹿客帮下单版</h3>
				<ul class="breadcrumb">
					<li><a>我的订单</a></li>
					<li class="active">测量订单</li>
				</ul>
			</div>
			<!--这里是写一些内容的  -->
			<section class="panel">
				<header class="panel-heading custom-tab turquoise-tab">
					<ul class="nav nav-tabs">
						<li class="active"><a onclick="clickOrders(0,'pay')">未付款</a></li>
						<li class=""><a onclick="clickOrders(0,'taking')">等待工人接单</a></li>
						<li class=""><a onclick="clickOrders(0,'order')">工人已接单</a></li>
						<li class=""><a onclick="clickOrders(0,'move')">工人已出发</a></li>
						<li class=""><a onclick="clickOrders(0,'done')">已完成</a></li>
					</ul>
				</header>
				<div class="panel-body">
					<div class="panel panel-default" style="border-bottom-width: 0px">
						<div class="panel-heading">查询条件</div>
						<form id="queryConditionForm">
							<table
								class="table table-striped table-bordered table-hover table-checkable"
								style="border-width: 0" id="datatable_ajax">
								<thead>
									<tr role="row" class="heading">
										<th align="center" width="5%">订单ID</th>
										<th width="8%">顾客姓名</th>
										<th width="8%">顾客手机号</th>
										<th width="15%">预约时间</th>
										<th width="15%">下单日期</th>
										<th width="5%">操作</th>
									</tr>
									<tr role="row" class="filter">
										<td><input type="text"
											class="form-control form-filter input-sm" name="indentID">
										</td>
										<td><input type="text"
											class="form-control form-filter input-sm" name="cuName"
											placeholder="顾客姓名"></td>
										<td>
											<div style="margin-bottom: 5px">
												<input type="text"
													class="form-control form-filter input-sm margin-bottom-5 clearfix"
													name="cuPhone" placeholder="顾客手机号" />
											</div>
										</td>
										<td>
											<div class="input-group date form_datetime"
												style="margin-bottom: 5px" data-link-field="">
												<input class="form-control" size="16" type="text" value=""
													name="subscribeTimeBegin" placeholder="起始时间" readonly>
												<span class="input-group-addon"><span
													class="glyphicon glyphicon-remove"></span></span> <span
													class="input-group-addon"><span
													class="glyphicon glyphicon-calendar"></span></span>
											</div> <input type="hidden" id="" value="" />
											<div class="input-group date form_datetime"
												style="margin-bottom: 5px">
												<input class="form-control" size="16" type="text" value=""
													name="subscribeTimeEnd" placeholder="结束时间" readonly>
												<span class="input-group-addon"><span
													class="glyphicon glyphicon-remove"></span></span> <span
													class="input-group-addon"><span
													class="glyphicon glyphicon-calendar"></span></span>
											</div> <input type="hidden" value="" />
										</td>
										<td><div class="input-group date form_datetime"
												style="margin-bottom: 5px">
												<input class="form-control" size="16" type="text" value=""
													name="beginTimeBegin" placeholder="起始时间" readonly>
												<span class="input-group-addon"><span
													class="glyphicon glyphicon-remove"></span></span> <span
													class="input-group-addon"><span
													class="glyphicon glyphicon-calendar"></span></span>
											</div> <input type="hidden" id="dtp_input1" value="" />
											<div class="input-group date form_datetime"
												style="margin-bottom: 5px">
												<input class="form-control" size="16" type="text" value=""
													name="beginTimeEnd" placeholder="结束时间" readonly> <span
													class="input-group-addon"><span
													class="glyphicon glyphicon-remove"></span></span> <span
													class="input-group-addon"><span
													class="glyphicon glyphicon-calendar"></span></span>
											</div></td>
										<td>
											<div style="margin-bottom: 5px">
												<button style="width: 70px" id="button_refreshQuery"
													type="button"
													class="btn btn-sm green btn-outline filter-submit margin-bottom">
													<i class="fa fa-search"></i> 查询
												</button>
											</div>
											<button style="width: 70px" type="button"
												onclick="$('#queryConditionForm')[0].reset()"
												class="btn btn-sm red btn-outline filter-cancel">
												<i class="fa fa-times"></i> 重置
											</button>
										</td>
									</tr>
								</thead>
							</table>
						</form>
					</div>
					<div class="tab-content">
						<div id="noPayOrders" class="tab-pane active">
							<table id="tb_watingPayIndent"></table>
						</div>
					</div>
				</div>
			</section>
			<!--内容结束  -->
		</div>
	</section>
	
	
	
	<!-- 商家信息 -->
	<jsp:include page="merchantInfo.jsp"></jsp:include>
	<jsp:include page="payMesure.jsp">
		<jsp:param value="0" name="type"/>
	</jsp:include>
	<!-- 输入密码 -->
	<jsp:include page="password.jsp"></jsp:include>
</body>
<!--pickers initialization-->
<script type="text/javascript">
	//弹出输入密码的modal框。
	var indentPrice = new Number(0);
	var TableInit = function() {
		var oTableInit = new Object();
		//初始化Table
		oTableInit.Init = function() {
			$('#tb_watingPayIndent')
					.bootstrapTable(
							{
								url : '${ctxPath}/indent/queryMeasureIndentByMerchant', //请求后台的URL（*）
								method : 'post', //请求方式（*）
								toolbar : '#toolbar', //工具按钮用哪个容器
								striped : true, //是否显示行间隔色
								cache : false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
								pagination : true, //是否显示分页（*）
								sortable : false, //是否启用排序
								sortName : 'beginTime',
								sortOrder : "desc", //排序方式
								queryParams : oTableInit.queryParams,//传递参数（*）
								sidePagination : "server", //分页方式：client客户端分页，server服务端分页（*）
								pageNumber : 1, //初始化加载第一页，默认第一页
								pageSize : 8, //每页的记录行数（*）
								pageList : [ 8, 25, 50, 100 ],
								search : false, //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
								strictSearch : false,
								showColumns : false, //是否显示所有的列
								showRefresh : true, //是否显示刷新按钮
								minimumCountColumns : 2, //最少允许的列数
								clickToSelect : false, //是否启用点击选中行
								height : 600, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
								uniqueId : "indentId", //每一行的唯一标识，一般为主键列
								showToggle : true, //是否显示详细视图和列表视图的切换按钮
								cardView : false, //是否显示详细视图
								detailView : false, //是否显示父子表
								contentType : 'application/x-www-form-urlencoded; charset=UTF-8',
								columns : [
										{
											field : 'indentId',
											title : '订单ID',
											width : '3%',
											align : "center"
										},
										{
											field : 'beginTime',
											title : '下单时间',
											width : '12%',
											align : "center"
										},
										{
											field : 'subscribeTime',
											title : '预约时间',
											width : '12%',
											align : "center"
										},
										{
											field : 'roomNumB',
											title : '测量房间数',
											width : '7%',
											align : "center"
										},
										{
											field : 'merchantsPrice',
											title : '订单价格',
											width : '7%',
											align : "center",
											formatter : function(value, row,
													index) {
												return value;

											}
										},
										{
											field : 'remark',
											title : '订单备注',
											width : '10%',
											align : "center"
										},
										/* 	{
											field : 'age',
											title : '工龄',
											width : '8%',
											align : "center"
										},
										{
											field : 'tag',
											title : '操作',
											width : '15%',
											align : "center",
											formatter : function(value, row,
													index) {
												return "<button class='btn btn-info btn-xs' onclick='javascript:viewWorkerDetialModalOpen("
														+ row.workerId
														+ ")'>查看详细</button>&nbsp;&nbsp;&nbsp;"
														+ "<button class='btn btn-success btn-xs' onclick='javascript:verifyWorkerThrough("
														+ row.workerId
														+ ")'>取消订单</button>";
											}
										}, */
										{
											field : 'customerAddress',
											title : '顾客姓名',
											width : '8%',
											align : "center",
											formatter : function(value, row,
													index) {
												return value.name;
											}
										},
										{
											field : 'tag',
											title : '顾客详细信息',
											width : '10%',
											align : "center",
											formatter : function(value, row,
													index) {
												return "<button class='btn btn-success btn-xs' onclick='javascript:viewCustomerDetialModalOpen("
														+ row.indentId
														+ ")'>查看顾客信息</button>";
											}
										},
										{
											field : 'tag2',
											title : '付款',
											width : '10%',
											align : "center",
											formatter : function(value, row,
													index) {
												return "<button class='btn btn-success btn-xs'  onclick='javascript:payIndentModalOpen("
														+ row.indentId
														+ ")'>付款</button>";
											}
										}, 
										{
											field : 'tag2',
											title : '取消订单',
											width : '10%',
											align : "center",
											formatter : function(value, row,
											index) {
												return "<button class='btn btn-success btn-xs'  onclick='javascript:quitIndentModalOpen("+ row.indentId+
														",0,"+row.customerId+")'>取消</button>";
											}
										},]
							});
		};

		//得到查询的参数
		oTableInit.queryParams = function(params) {
			var temp = { //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
				limit : params.limit, //页面大小
				offset : params.offset, //页码
				order : params.order,
				sort : params.sort,
				indentID : $("input[name='indentID']").val(),
				subscribeTimeBegin : $("input[name='subscribeTimeBegin']")
						.val(),
				subscribeTimeEnd : $("input[name='subscribeTimeEnd']").val(),
				beginTimeBegin : $("input[name='beginTimeBegin']").val(),
				beginTimeEnd : $("input[name='beginTimeEnd']").val(),
				cuName : $("input[name='cuName']").val(),
				cuPhone : $("input[name='cuPhone']").val(),
				indentStatus : 4,
			};
			return temp;
		};
		return oTableInit;
	};
	$(function() {
		$("#payIndentModal input[name='addPrice']").TouchSpin({
			min : 0,
			max : 1000,
			//step : 5,
			boostat : 5,
			maxboostedstep : 10,
			postfix : '元'
		});
		//1.初始化Table
		var oTable = new TableInit();
		oTable.Init();
		$('.form_datetime').datetimepicker({
			language : 'zh-CN',
			format : "yyyy-mm-dd hh:ii:ss",
			weekStart : 1,
			todayBtn : 1,
			autoclose : 1,
			todayHighlight : 1,
			startView : 2,
			forceParse : 0,
			showMeridian : 1
		});
		$('.form_date').datetimepicker({
			//language : 'fr',
			weekStart : 1,
			todayBtn : 1,
			autoclose : 1,
			todayHighlight : 1,
			startView : 2,
			minView : 2,
			forceParse : 0
		});
		$('.form_time').datetimepicker({
			//language : 'fr',
			weekStart : 1,
			todayBtn : 1,
			autoclose : 1,
			todayHighlight : 1,
			startView : 1,
			minView : 0,
			maxView : 1,
			forceParse : 0
		});
		$("#button_refreshQuery").click(function() {
			var opt = {
				pageNumber : 1,
				query : {
					offset : 0
				}
			};
			//从新开始计数
			$("#tb_watingPayIndent").bootstrapTable('refresh', opt);
		});
	});

	//查看那个订单的那个用户
	function viewCustomerDetialModalOpen(id) {
		var viewRow = $('#tb_watingPayIndent').bootstrapTable(
				'getRowByUniqueId', id);
		$("#viewCustomerDetialModal #txt_customerName").val(
				viewRow.customerAddress.name);
		$("#txt_customerPhoneNumber").val(viewRow.customerAddress.phone);
		$("#txt_customerAddress").val(viewRow.customerAddress.customerAddress);
		$("#txt_customerRemark").val(viewRow.remark);
		$('#viewCustomerDetialModal').modal('show');
	}
	//打开支付面板
	function payIndentModalOpen(indentId) {
		var viewRow = $('#tb_watingPayIndent').bootstrapTable(
				'getRowByUniqueId', indentId);
		$("input[name='indentID']").val(indentId);
		indentPrice = viewRow.merchantsPrice;
		$("#payIndentForm #totalPrice").val(indentPrice + 5);
		$("#payIndentModal").modal('show');
	}
	// 支付订单信息
	//支付
	function payMeasureIndent(url) {
		$("#payIndentForm").attr("action", url);
		$("#payIndentForm").submit();
	}
	//////////////////余额支付-END///////////////////////////////
	//页面加载时绑定按钮点击事件
/* 	$(function() {
		$("#sureBtn").click(function() {
			refresh();
		});
	}); */
	//点击按钮调用的方法
	function refresh() {
		window.location.reload();//刷新当前页面.
		//或者下方刷新方法
		//parent.location.reload()刷新父亲对象（用于框架）--需在iframe框架内使用
		// opener.location.reload()刷新父窗口对象（用于单开窗口
		//top.location.reload()刷新最顶端对象（用于多开窗口）
	}
	// 预览订单的价格
	$("#payIndentForm input").change(function() {
		countTotalIndentPrice();
	});
	// 计算订单的总价格
	function countTotalIndentPrice() {
		var totalIndentPrice = new Number(indentPrice);
		totalIndentPrice = parseInt(totalIndentPrice)
				+ parseInt($("#payIndentForm input[name='addPrice']").val());
		if ($("#payIndentForm input[name='relievedBao']:checked").val() == 1) {
			totalIndentPrice = totalIndentPrice + 5;
		}
		$("#payIndentForm #totalPrice").val(totalIndentPrice);
	}
</script>
<!-- toastr提示框的使用 -->
<script src="${ctxPath}/static/js/security/security.js"></script>
<script src="${ctxPath}/static/js/useful-toastr/toastr.min.js"></script>
<link href="${ctxPath}/static/js/useful-toastr/toastr.min.css"
	rel="stylesheet" />
<script src="${ctxPath}/static/js/useful-ewin/Ewin.js"></script>
<script type="text/javascript"
	src="${ctxPath}/static/js/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript"
	src="${ctxPath}/static/js/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript"
	src="${ctxPath}/static/js/orders/public.js"></script>
<script type="text/javascript"
	src="${ctxPath}/static/js/taskManage/public.js"></script>
<!-- tables插件的引用 -->
<script src="${ctxPath}/static/js/bootstrap-table/bootstrap-table.js"></script>
<link href="${ctxPath}/static/js/bootstrap-table/bootstrap-table.css"
	rel="stylesheet" />
<script
	src="${ctxPath}/static/js/bootstrap-table/locale/bootstrap-table-zh-CN.js"></script>
</html>
